package com.kx.springmybatis.mapper;

import com.kx.springmybatis.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName UserMapper
 * @Author Sun
 * @Date 2021/5/18 22:20
 */
public interface UserMapper {

    @Select("select * from users where id=#{id}")
    User getUserById(long id);

    @Insert("INSERT INTO users (username,password,age,address,birthday) values(#{username},#{password},#{age},#{address},#{birthday})")
    void addUser(User user);

    @Update("UPDATE users set username=#{username},password=#{password},age=#{age},address=#{address},birthday=#{birthday} WHERE id=#{id}")
    int updateUser(User user);

    @Delete("DELETE FROM users where id=#{id}")
    int deleteUserById(long id);

}
